<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            outline: none;
            cursor: pointer;
            border: 0;
            background-color: lightcoral;
        }
    </style>
</head>
<body>
    <button>开灯</button>

    <script>
        var button = document.querySelector('button');
        var body = document.body
        var switch1 = true;
        button.onclick = function (){
            if(switch1) {
                body.style.backgroundColor = 'black'
                switch1 = false;
            }else {
                body.style.backgroundColor = 'red'
                switch1 = true;
            }
        }
    </script>
</body>
</html>